package com.asdc.demo.durable;

import com.asdc.demo.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.MessageProperties;

import java.util.Scanner;

/**
 * @ClassName ProducerDura
 * @Author bsy
 * @Description Durable 持久化
 * 模拟场景：持久化
 * @Date 2022/3/12 16:18
 * @Version 1.0
 */
public class ProducerDura {
    private static final String QUEUE_NAME = "QUEUE_DUR_VVYX";

    public static void main(String[] args) throws Exception {
        try (Channel channel = RabbitMqUtils.getChannel()) {
            channel.queueDeclare(QUEUE_NAME, true, false, false, null);
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入:");
            while (scanner.hasNext()){
                String msg = scanner.next();
                channel.basicPublish("",QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN,msg.getBytes());
            }
        }
    }
}
